home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: Example using vfprintf
- Date: 29 Feb 1996 18:39:03 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4h5gv8$fvs@solutions.solon.com>
- References: <raffelmDnK19L.IH6@netcom.com> <raffelmDnK2ww.39r@netcom.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <raffelmDnK2ww.39r@netcom.com>,
- Matt Raffel <raffelm@netcom.com> wrote:
-
- >void lprintf(char *pszFormat, ...)
- >{
- > FILE *pstFile = NULL;
- > va_list pstMarker;
-
- This highlights the basic brokenness of the faux Hungarian botch Microsoft
- encourages. What kind of idiot would use "pst" for something which is
- a "char *"? Oh, wait, you mean it's a long on your system, and a pointer
- to struct on another system, and just a plain struct on another? Gee,
- maybe it's *an opaque type*, and you should never pretend to know what's in
- it.
-
- The only sane "type prefix" for a va_list would be something like va, or
- v_l.
-
- And, of course, I agree with both GNU and Rob Pike - mixed case variable
- names like ICantReadThis are *stupid*. If you want non-breaking spaces,
- use underscore, which is a non-breaking space.
-
- > va_start(pstMarker);
- > pstFile = fopen("llog.txt", "wt+");
-
- !!!
- This is almost certainly *NOT* what you want:
- 1. The "t" mode flag is meaningless - except for the fact that it causes
- any further text (such as the "+") to be ignored.
- 2. The + is meaningless; why indicate update (read/write) when you don't
- plan to write?
- 3. THE 'w' FLAG WILL TRUNCATE THE FILE ON OPEN! This is *NOT* good for
- a logging feature.
-
- > if (pstFile)
- > {
- > vfprintf(pstFile, pszFormat, pstMarker);
- > fclose(pstFile);
- > }
- > va_end(pstMarker);
- >}
-
- Apart from the poor naming, this is probably correct.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-